import torch

def get_modules_by_type(
    model: torch.nn.Module,
    module_type: type
) -> dict[str, torch.nn.Module]:
    modules = {}
    for name, module in model.named_modules():
        if isinstance(module, module_type):
            modules[name] = module
    return modules

def get_parameters_by_module_type(
    model: torch.nn.Module,
    module_type: type[torch.nn.Module]
) -> dict[str, torch.nn.Parameter]:
    parameters = {}
    for name, module in model.named_modules():
        if isinstance(module, module_type):
            parameters.update(module.named_parameters(name))
    return parameters
